﻿//-----------------------------------------------------------------------------------
// WebTestRequest Plugin Template version 1.0
//-----------------------------------------------------------------------------------
using System;
using Microsoft.VisualStudio.TestTools.WebTesting;
using System.Threading;

namespace WebServicesTesting.Automation.WebTest.PlugIns
{
    [System.ComponentModel.DisplayName("DelayPlugin")]
    [System.ComponentModel.Description("TODO: Add a more detailed description of CachePlugin extraction rule.")]
    public class DelayPlugin : WebTestRequestPlugin
    {
        #region Constructors
        /// <summary>
        /// Default Constructor, remove if not needed
        /// </summary>
        public DelayPlugin()
        {
        }

        #endregion // Constructors

        

       
        #region Properties
        /*
 * Public properties on the class will be surfaced to the user in the VS UI.
 * Only string, int, and bool types are allowed.
 */
        /*
                /// <summary>
                /// Sample string property
                /// </summary>
                private string m_myStringProperty;
                [System.ComponentModel.DisplayName("My String Property")]
                [System.ComponentModel.Description("Enter a long description for this property.")]
                [System.ComponentModel.DefaultValue("MyString")]
                public string MyStringProperty
                {
                    get { return m_myStringProperty; }
                    set { m_myStringProperty = value; }
                }
        */
        #endregion //Properties

        #region Overrides
        /*
 * To see a list of overridable methods type "public override " at the class scope.
 */

        /// <summary>
        /// Fires before each request
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void PreRequest(object sender, PreRequestEventArgs e)
        {
            
        }

        /// <summary>
        /// Fires after each request
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void PostRequest(object sender, PostRequestEventArgs e)
        {

           
            double str =Convert.ToDouble(e.WebTest.Context["Delay"].ToString());
             //delay =TimeSpan.Parse(str);
            Thread.Sleep(TimeSpan.FromSeconds(str));
             
           
         }



        }
        #endregion // Overrides
    }

